# _*_ encoding:utf-8 _*_

from rest_framework.viewsets import ModelViewSet
from rest_framework.permissions import IsAdminUser
from rest_framework.response import Response

from goods.models import SKUImage, SKU
from meiduo_admin.serializers.image_serializers import ImageModelSerializer
from meiduo_admin.serializers.sku_serializers import SKUSimpleModelSerializer
from meiduo_admin.paginations import MyPage


class SKUImageView(ModelViewSet):

    permission_classes = [IsAdminUser]

    queryset = SKUImage.objects.all()
    serializer_class = ImageModelSerializer
    pagination_class = MyPage

    def simple_sku(self, request):

        queryset = SKU.objects.all()

        serializer = SKUSimpleModelSerializer(queryset, many=True)

        return Response(serializer.data)



